package org.sparkle.db.user;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.sparkle.db.basic.BaseVO;
import org.sparkle.db.group.GroupVO;

import com.avaje.ebean.validation.Email;
import com.avaje.ebean.validation.NotNull;

@Entity
@Table(name = "spk_user")
public class UserVO extends BaseVO {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8204862037648260051L;

	@NotNull
	private String username;
	private String fname;
	private String lname;
	@NotNull
	@Email
	private String email;
	@ManyToMany( mappedBy="users",cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	private List<GroupVO> groups;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getFname() {
		return fname;
	}

	public void setFname(String fname) {
		this.fname = fname;
	}

	public String getLname() {
		return lname;
	}

	public void setLname(String lname) {
		this.lname = lname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public List<GroupVO> getGroups() {
		if(groups==null)
			groups=new ArrayList<GroupVO>(0);
		return groups;
	}

	public void setGroups(List<GroupVO> groups) {
		this.groups = groups;
	}

}
